﻿using BP.Web;
using BP.En;
namespace BP.CCFast.DataBank
{
    /// <summary>
    /// 属性
    /// </summary>
    public class DataBankAttr : EntityNoNameAttr
    {
        /// <summary>
        /// 内容
        /// </summary>
        public const string Docs = "Docs";
    }
    /// <summary>
    /// 独立方法
    /// </summary>
    public class DataBank : EntityNoName
    {
        #region 构造方法
        /// <summary>
        /// 权限控制
        /// </summary>
        public override UAC HisUAC
        {
            get
            {
                UAC uac = new UAC();
                if (WebUser.IsAdmin)
                {
                    uac.IsUpdate = false;
                    return uac;
                }
                return base.HisUAC;
            }
        }
        /// <summary>
        /// 独立方法
        /// </summary>
        public DataBank()
        {
        }
        public DataBank(string no)
        {
            this.No = no;
            this.Retrieve();
        }
        /// <summary>
        /// 重写基类方法
        /// </summary>
        public override Map EnMap
        {
            get
            {
                if (this._enMap != null)
                    return this._enMap;

                Map map = new Map("Sys_DataBank", "数据银行");

                map.AddTBStringPK(DataBankAttr.No, null, "编号", true, true, 0, 50, 10);
                map.AddTBString(DataBankAttr.Name, null, "方法名", true, false, 0, 300, 10, true);
                map.AddTBStringDoc(DataBankAttr.Docs, null, "内容", true, false, true);
                map.AddTBString("MD5", null, "加密值", true, false, 0, 300, 10, true);

                this._enMap = map;
                return this._enMap;
            }
        }
        #endregion

        #region 执行方法.
        protected override bool beforeInsert()
        {
            return base.beforeInsert();
        }
        #endregion 执行方法.
    }
    /// <summary>
    /// 独立方法s
    /// </summary>
    public class DataBanks : EntitiesNoName
    {
        /// <summary>
        /// 独立方法
        /// </summary>
        public DataBanks() { }
        /// <summary>
        /// 得到它的 Entity 
        /// </summary>
        public override Entity GetNewEntity
        {
            get
            {
                return new DataBank();
            }
        }

        #region 为了适应自动翻译成java的需要,把实体转换成List.
        /// <summary>
        /// 转化成 java list,C#不能调用.
        /// </summary>
        /// <returns>List</returns>
        public System.Collections.Generic.IList<DataBank> ToJavaList()
        {
            return (System.Collections.Generic.IList<DataBank>)this;
        }
        /// <summary>
        /// 转化成list
        /// </summary>
        /// <returns>List</returns>
        public System.Collections.Generic.List<DataBank> Tolist()
        {
            System.Collections.Generic.List<DataBank> list = new System.Collections.Generic.List<DataBank>();
            for (int i = 0; i < this.Count; i++)
            {
                list.Add((DataBank)this[i]);
            }
            return list;
        }
        #endregion 为了适应自动翻译成java的需要,把实体转换成List.
    }
}
